import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class HomeNotice extends StatelessWidget {
  final List list;
  final bool loadSuccess;

  HomeNotice({Key key, this.list, this.loadSuccess}) : super(key: key);

  Widget _buildMsg() {
    if(loadSuccess) {
      if(list.length > 0) {
        return Text(list[0]['content'],
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
          style: TextStyle(color: Color(0xFF333333), fontSize: 13),
        );
      }else {
        return Text('');
      }
    }else {
      return Text('');
    }
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return GestureDetector(
      onTap: () {
        Navigator.pushNamed(context, "/message");
      },
      child: Container(
        width: 720.w,
        height: 90.w,
        padding: EdgeInsets.only(left: 30.w, right: 30.w),
        margin: EdgeInsets.fromLTRB(15.w, 276.w, 15.w, 0),
        decoration: BoxDecoration(
          border: Border.all(color: Colors.white),
          borderRadius: BorderRadius.circular(20.w),
          color: Colors.white,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Container(
              child: Row(
                children: <Widget>[
                  Image.asset('assets/notice.png',
                    width: 35.w,
                  ),
                  Container(
                    width: 520.w,
                    margin: EdgeInsets.only(left: 26.w),
                    child: _buildMsg(),
                  )
                ],
              ),
            ),
            Image.asset('assets/arrow_r_n.png', width: 12.w)
          ],
        ),
      ),
    );
  }
}